load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test_suite")

package(default_visibility = ["//visibility:public"])

DEV_DATA = [
    "@mainnet_canisters//:registry.wasm.gz",
    "//rs/registry/canister:registry-canister",
    "//rs/pocket_ic_server:pocket-ic-server",
    "//rs/boundary_node/salt_sharing:salt_sharing_canister",
]

DEV_ENV = {
    "CARGO_MANIFEST_DIR": "rs/nns/integration_tests",
    "REGISTRY_CANISTER_WASM_PATH": "$(rootpath //rs/registry/canister:registry-canister)",
    "MAINNET_REGISTRY_CANISTER_WASM_PATH": "$(rootpath @mainnet_canisters//:registry.wasm.gz)",
    "POCKET_IC_BIN": "$(rootpath //rs/pocket_ic_server:pocket-ic-server)",
    "SALT_SHARING_CANISTER_WASM_PATH": "$(rootpath //rs/boundary_node/salt_sharing:salt_sharing_canister)",
}

rust_library(
    name = "salt_sharing_canister_integration_tests",
    testonly = True,
    srcs = glob(["src/**/*.rs"]),
    crate_name = "salt_sharing_canister_integration_tests",
    deps = [
        # Keep sorted.
        "//packages/ic-http-types",
        "//rs/boundary_node/salt_sharing/api:salt_sharing_api",
        "//rs/nervous_system/integration_tests:nervous_system_integration_tests",
        "//rs/types/base_types",
        "@crate_index//:assert_matches",
        "@crate_index//:candid",
        "@crate_index//:chrono",
        "@crate_index//:ic-management-canister-types",
        "@crate_index//:serde",
        "@crate_index//:serde_json",
        "@crate_index//:tokio",
    ] + select({
        "@rules_rust//rust/platform:wasm32-unknown-unknown": [],
        "//conditions:default": [
            "//packages/pocket-ic",
            "//rs/crypto/sha2",
            "//rs/nns/constants",
            "//rs/nns/test_utils",
            "//rs/registry/keys",
            "//rs/registry/transport",
            "//rs/rust_canisters/canister_test",
        ],
    }),
)

rust_test_suite(
    name = "integration_tests_test",
    srcs = glob(
        ["tests/**/*.rs"],
    ),
    data = DEV_DATA,
    env = DEV_ENV,
    deps = [
        # Keep sorted.
        ":salt_sharing_canister_integration_tests",
        "//packages/ic-http-types",
        "//rs/boundary_node/salt_sharing/api:salt_sharing_api",
        "//rs/nervous_system/integration_tests:nervous_system_integration_tests",
        "//rs/types/base_types",
        "@crate_index//:assert_matches",
        "@crate_index//:candid",
        "@crate_index//:chrono",
        "@crate_index//:ic-management-canister-types",
        "@crate_index//:serde",
        "@crate_index//:serde_json",
        "@crate_index//:tokio",
    ] + select({
        "@rules_rust//rust/platform:wasm32-unknown-unknown": [],
        "//conditions:default": [
            "//packages/pocket-ic",
            "//rs/crypto/sha2",
            "//rs/nns/constants",
            "//rs/nns/test_utils",
            "//rs/registry/keys",
            "//rs/registry/transport",
            "//rs/rust_canisters/canister_test",
        ],
    }),
)
